#include <iostream>
#include <cstdio>
using namespace std;
int a[105][105],b[105][105]; 
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	/*
	(1,1) (n,1)
	(1,2) (n-1,1)
	(2,3) (1,2)
	
	*/
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			b[i][j]=a[n+1-j][i];
			cout<<b[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}
